package config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.mangofactory.swagger.configuration.SpringSwaggerConfig;
import com.mangofactory.swagger.plugin.EnableSwagger;
import com.mangofactory.swagger.plugin.SwaggerSpringMvcPlugin;
import com.wordnik.swagger.model.ApiInfo;

@Configuration
@EnableSwagger
public class MySwaggerConfig {
	private SpringSwaggerConfig springSwaggerConfig;

	   /**
	    * Required to autowire SpringSwaggerConfig
	    */
	   @Autowired
	   public void setSpringSwaggerConfig(SpringSwaggerConfig springSwaggerConfig) {
	      this.springSwaggerConfig = springSwaggerConfig;
	   }

	   /**
	    * Every SwaggerSpringMvcPlugin bean is picked up by the swagger-mvc framework - allowing for multiple
	    * swagger groups i.e. same code base multiple swagger resource listings.
	    */
	   @Bean
	   public SwaggerSpringMvcPlugin customImplementation(){
		   SwaggerSpringMvcPlugin ssmp = new SwaggerSpringMvcPlugin(this.springSwaggerConfig)
		   .apiInfo(apiInfo())
		   .swaggerGroup("api-docs").build();
	      return ssmp;
	   }
	   
	private ApiInfo apiInfo() {
		ApiInfo apiInfo = new ApiInfo(
				"OSE API SPECIFICATION",
				"This is the ose api specification,here you can dig into the details of api and do api testing as well.",
				"",
				"",
				"",
				"");
		return apiInfo;
	}
}
